load("/data/general/npcs/elemental.lua")

-- no rarity elementals to guard the gates, and one special one to replace one of the guardians
newEntity{ base = "BASE_NPC_ELEMENTAL", perm = true, unique = true,
	define_as = "CHAOS_SPAWN", subtype = "chaos",
	name = "chaos elemental", color=colors.PURPLE,
	shader = "chaos_hue", faction = "chaos",
	desc = "Ever strange, ever shifting, this morphing elemental looks upon you with scorn and hate.",
	level_range = {15, 50}, exp_worth = 1,
	max_life = resolvers.rngavg(10,12),
	stats = { str=17, dex=17, con=17 },
	combat = { damtype=DamageType.CHAOS },
	resists = { [DamageType.COLD] = -20, [DamageType.EARTH] = -20, [DamageType.FIRE] = -20, [DamageType.LIGHTNING] = -20, [DamageType.MANA] = -20, [DamageType.MANA] = -75, },
}

newEntity{ base = "BASE_NPC_ELEMENTAL", perm = true, unique = true,
	define_as = "MANA_GUARD", subtype = "mana",
	name = "mana elemental", color=colors.ORCHID,
	desc = "This strange scintillating elemental seems to blink in and out of reality.  Yet at the same time, this one seems to be writhing in powerful energies.",
	level_range = {15, 50}, exp_worth = 1,
	rank = 1, unique = true, 
	max_life = resolvers.rngavg(15,20),
	stats = { str=15, dex=15, con=15 },
	ai = "dumb_talented_simple", ai_state = { talent_in=3, },
	combat = { damtype=DamageType.MANA },
	resists = { [DamageType.COLD] = 50, [DamageType.EARTH] = 50, [DamageType.FIRE] = 50, [DamageType.LIGHTNING] = 50, [DamageType.MANA] = 50, [DamageType.CHAOS] = -50, },
	invulnerable = true, faction = "mana",
	never_move = true, no_blow = true,
	on_hit = function(self, who)
		if who == game.player then
			if who.faction == "chaos" then
				self.never_move = false
				self.no_blow = false
				self.invulnerable = false
			else
				local Chat = require("engine.Chat")
				local chat = Chat.new("portal-mana", self, game.player)
				chat:invoke()
			end
		end
	end,
	can_talk = "portal-mana",
}

newEntity{ base = "BASE_NPC_ELEMENTAL", perm = true, unique = true,
	define_as = "EARTH_GUARD", subtype = "earth",
	name = "earth elemental", color=colors.UMBER,
	desc = "This brawny being, seemingly made of stone and earth and as tall as a mountain, lumbers toward you.",
	level_range = {15, 50}, exp_worth = 1,
	max_life = resolvers.rngavg(12,15),
	stats = { str=11, dex=8, con=12 },
	combat = { damtype=DamageType.EARTH },
	resists = { [DamageType.EARTH] = 50, [DamageType.LIGHTNING] = -50, },
	invulnerable = true, faction = "earth",
	never_move = true, no_blow = true,
	on_hit = function(self, who)
		if who == game.player then self.never_move = false self.no_blow = false self.invulnerable = false end	-- remove special stuff
	end,
	on_acquire_target = function(self, who)
		if who == game.player then
			local Chat = require("engine.Chat")
			local chat = Chat.new("portals", self, game.player)
			chat:invoke()
		end
	end,
	can_talk = "portals",
}

newEntity{ base = "BASE_NPC_ELEMENTAL", perm = true, unique = true,
	define_as = "FIRE_GUARD", subtype = "fire",
	name = "fire elemental", color=colors.RED,
	desc = "Flames flicker and dance around, is this a cozy campfire or a raging inferno?",
	level_range = {15, 50}, exp_worth = 1,
	max_life = resolvers.rngavg(9,11),
	stats = { str=12, dex=11, con=9 },
	combat = { dam=3, damtype=DamageType.FIRE },
	resists = { [DamageType.FIRE] = 50, [DamageType.COLD] = -50, },
	invulnerable = true, faction = "fire",
	never_move = true, no_blow = true,
	on_hit = function(self, who)
		if who == game.player then self.never_move = false self.no_blow = false self.invulnerable = false end	-- remove special stuff
	end,
	on_acquire_target = function(self, who)
		if who == game.player then
			local Chat = require("engine.Chat")
			local chat = Chat.new("portals", self, game.player)
			chat:invoke()
		end
	end,
	can_talk = "portals",
}

newEntity{ base = "BASE_NPC_ELEMENTAL", perm = true, unique = true,
	define_as = "AIR_GUARD", subtype = "air",
	name = "air elemental", color=colors.YELLOW,
	desc = "Nigh invisible, this elemental causes the air around it to charge up as it dashes toward you with speed and grace.",
	level_range = {15, 50}, exp_worth = 1,
	max_life = resolvers.rngavg(7,9),
	stats = { str=9, dex=15, con=8 },
	combat = { damtype=DamageType.LIGHTNING },
	resists = { [DamageType.LIGHTNING] = 50, [DamageType.EARTH] = -50, },
	invulnerable = true, faction = "air",
	never_move = true, no_blow = true,
	on_hit = function(self, who)
		if who == game.player then self.never_move = false self.no_blow = false self.invulnerable = false end	-- remove special stuff
	end,
	on_acquire_target = function(self, who)
		if who == game.player then
			local Chat = require("engine.Chat")
			local chat = Chat.new("portals", self, game.player)
			chat:invoke()
		end
	end,
	can_talk = "portals",
}

newEntity{ base = "BASE_NPC_ELEMENTAL", perm = true, unique = true,
	define_as = "WATER_GUARD", subtype = "water",
	name = "water elemental", color=colors.BLUE,
	desc = "This elemental takes the form of a crushing wave that rises up and engulfs its surroundings.",
	level_range = {15, 50}, exp_worth = 1,
	max_life = resolvers.rngavg(9,11),
	stats = { str=11, dex=10, con=11 },
	combat = { damtype=DamageType.COLD },
	resists = { [DamageType.COLD] = 50, [DamageType.FIRE] = -50, },
	invulnerable = true, faction = "water",
	never_move = true, no_blow = true,
	on_hit = function(self, who)
		if who == game.player then self.never_move = false self.no_blow = false self.invulnerable = false end	-- remove special stuff
	end,
	on_acquire_target = function(self, who)
		if who == game.player then
			local Chat = require("engine.Chat")
			local chat = Chat.new("portals", self, game.player)
			chat:invoke()
		end
	end,
	can_talk = "portals",
}
